#include <iostream>
#include <iterator>
#include <vector>
#include <list>
#include <algorithm>
#include <fstream>
#include <string>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/timeb.h>

#include "CRandom.h"

using namespace std;

int main(int argc,char *argv[])
{
	pid_t pid = fork();
	if(pid<0) {
		cerr << "fork() error" << endl;
		exit(-1);
	}
	else if(pid==0) {
		CRandom child_random;

		for(int i=0;i<5;i++) {
			cout << "[child]generate number = " << child_random.millitime() << "." <<  child_random.generate() << endl;

			char tmp[1024];
			sprintf(tmp, "%lld", child_random.millitime());
			cout << "### " << tmp << endl;
		}

		exit(0);
	}
	else {
		CRandom parent_random;

		for(int i=0;i<5;i++) {
			cout << "[parent]generate number = " << parent_random.millitime()  << "." << parent_random.generate() << endl;
		}

		exit(0);
	}
}
